with open('app.py', 'r', encoding='utf-8') as f:
    content = f.read()
    
# 删除INDEX_HTML字符串定义
start_marker = '# HTML 模板\nINDEX_HTML = \'\'\''
end_marker = '\'\'\'\n\ndef main'
if start_marker in content and end_marker in content:
    start_idx = content.find(start_marker)
    end_idx = content.find(end_marker) + len('\'\'\'\n')
    new_content = content[:start_idx] + 'def main' + content[end_idx + len('\ndef main'):]
    
    with open('app_fixed.py', 'w', encoding='utf-8') as f_out:
        f_out.write(new_content)
    print('文件已修复并保存为 app_fixed.py')
else:
    print('未找到标记，无法修复')
